home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 24.4 KB | 854 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWMemorH.cpp
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWPLATME_H
- #include <FWPlatMe.h>
- #endif
-
- #ifndef FWMEMORH_H
- #include <FWMemorH.h>
- #endif
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __STDIO__
- #include <stdio.h>
- #endif
-
-
- //========================================================================================
- // CLASS FW_CMemoryHook (FW_DEBUG only)
- //========================================================================================
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHook::FW_CMemoryHook
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_CMemoryHook::FW_CMemoryHook()
- {
- fNextHook = fPreviousHook = this;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHook::~FW_CMemoryHook
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_CMemoryHook::~FW_CMemoryHook()
- {
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHook::AboutToAllocate
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_BlockSize FW_CMemoryHook::AboutToAllocate(FW_BlockSize size)
- {
- return size;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHook::DidAllocate
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void *FW_CMemoryHook::DidAllocate(void* blk, FW_BlockSize)
- {
- return blk;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHook::AboutToFW_BlockSize
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void *FW_CMemoryHook::AboutToBlockSize(void* blk)
- {
- return blk;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHook::AboutToFree
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void *FW_CMemoryHook::AboutToFree(void* blk)
- {
- return blk;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHook::AboutToRealloc
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHook::AboutToRealloc(void* &, FW_BlockSize &)
- {
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHook::DidRealloc
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void *FW_CMemoryHook::DidRealloc(void *blk, FW_BlockSize)
- {
- return blk;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHook::AboutToReset
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHook::AboutToReset()
- {
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHook::Comment
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHook::Comment(const char*)
- {
- }
- #endif
-
-
- //========================================================================================
- // CLASS FW_CMemoryHookList (FW_DEBUG only)
- //========================================================================================
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHookList::FW_CMemoryHookList
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_CMemoryHookList::FW_CMemoryHookList()
- {
- fCurrentHook = &fHead;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHookList::Add
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHookList::Add(FW_CMemoryHook* aMemoryHook)
- {
- // Add at the fEnd of the list by adding after the last hook in the list.
-
- FW_CMemoryHook* afterHook = fHead.fPreviousHook;
-
- aMemoryHook->fNextHook = afterHook->fNextHook;
- afterHook->fNextHook->fPreviousHook = aMemoryHook;
- aMemoryHook->fPreviousHook = afterHook;
- afterHook->fNextHook = aMemoryHook;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHookList::Remove
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHookList::Remove(FW_CMemoryHook* aMemoryHook)
- {
- aMemoryHook->fPreviousHook->fNextHook = aMemoryHook->fNextHook;
- aMemoryHook->fNextHook->fPreviousHook = aMemoryHook->fPreviousHook;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHookList::First
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_CMemoryHook* FW_CMemoryHookList::First()
- {
- fCurrentHook = fHead.fNextHook;
- return fCurrentHook != &fHead ? fCurrentHook : NULL;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHookList::Next
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_CMemoryHook* FW_CMemoryHookList::Next()
- {
- if (fCurrentHook != &fHead)
- fCurrentHook = fCurrentHook->fNextHook;
- return fCurrentHook != &fHead ? fCurrentHook : NULL;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHookList::Previous
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_CMemoryHook* FW_CMemoryHookList::Previous()
- {
- if (fCurrentHook != &fHead)
- fCurrentHook = fCurrentHook->fPreviousHook;
- return fCurrentHook != &fHead ? fCurrentHook : NULL;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHookList::Last
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_CMemoryHook* FW_CMemoryHookList::Last()
- {
- fCurrentHook = fHead.fPreviousHook;
- return fCurrentHook != &fHead ? fCurrentHook : NULL;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHookList::~FW_CMemoryHookList
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_CMemoryHookList::~FW_CMemoryHookList()
- {
- }
- #endif
-
-
- //========================================================================================
- // CLASS FW_CMemoryHeap
- //========================================================================================
-
- #ifdef FW_DEBUG
- const char *FW_CMemoryHeap::kDefaultDescription = "FW_CMemoryHeap";
- #endif
-
- FW_CMemoryHeap *FW_CMemoryHeap::fHeapList; // Don't initialize!
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::GetFirstHeap
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_CMemoryHeap *FW_CMemoryHeap::GetFirstHeap()
- {
- return fHeapList;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::Allocate
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void *FW_CMemoryHeap::Allocate(FW_BlockSize size)
- {
- FW_BlockSize allocatedSize;
-
- #ifdef FW_DEBUG
- size = this->CallAboutToAllocateHooks(size);
- #endif
-
- void *blk = this->DoAllocate(size, allocatedSize);
-
- if (blk != NULL)
- {
- if (fZapOnAllocate)
- {
- char *chrBlk = (char *) blk;
- for (FW_BlockSize i = 0; i < allocatedSize; i++)
- *chrBlk++ = 0;
- }
-
- fBytesAllocated += allocatedSize;
- fNumberAllocatedBlocks++;
- }
-
- #ifdef FW_DEBUG
- blk = this->CallDidAllocateHooks(blk, size);
- #endif
-
- return blk;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::FW_BlockSize
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_BlockSize FW_CMemoryHeap::BlockSize(const void *blk) const
- {
- if (blk == NULL)
- return 0;
-
- #ifdef FW_DEBUG
- if (fAutoValidation)
- this->ValidateAndReport((void*)blk);
-
- blk = ((FW_CMemoryHeap *) this)->CallAboutToFW_BlockSizeHooks((void*)blk);
- #endif
-
- return this->DoBlockSize((void*)blk);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::BytesAllocated
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- unsigned long FW_CMemoryHeap::BytesAllocated() const
- {
- return fBytesAllocated;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::Free
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::Free(void* blk)
- {
- if (blk == NULL)
- return;
-
- #ifdef FW_DEBUG
- if (fAutoValidation)
- this->ValidateAndReport(blk);
-
- blk = this->CallAboutToFreeHooks(blk);
- #endif
-
- FW_BlockSize allocatedSize = (FW_BlockSize) this->DoBlockSize(blk);
-
- if (fZapOnFree)
- {
- char *chrBlk = (char *) blk;
- for (FW_BlockSize i = 0; i < allocatedSize; i++)
- *chrBlk++ = 0;
- }
-
- this->DoFree(blk);
-
- fBytesAllocated -= allocatedSize;
- fNumberAllocatedBlocks--;
- }
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::GetAutoValidation (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- Boolean FW_CMemoryHeap::GetAutoValidation() const
- {
- return fAutoValidation;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::GetDescription (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- const char *FW_CMemoryHeap::GetDescription() const
- {
- return fDescription;
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::GetNextHeap
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_CMemoryHeap *FW_CMemoryHeap::GetNextHeap() const
- {
- return fNextHeap;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::GetZapOnAllocate
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- Boolean FW_CMemoryHeap::GetZapOnAllocate() const
- {
- return fZapOnAllocate;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::GetZapOnFree
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- Boolean FW_CMemoryHeap::GetZapOnFree() const
- {
- return fZapOnFree;
- }
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::InstallHook (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::InstallHook(FW_CMemoryHook *memoryHook)
- {
- fMemoryHookList.Add(memoryHook);
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::IsValidBlock (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- Boolean FW_CMemoryHeap::IsValidBlock(void *blk) const
- {
- if (blk == NULL)
- return false;
-
- if (this->IsMyBlock(blk))
- return DoIsValidBlock(blk);
- else
- return false;
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::NumberAllocatedBlocks
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- unsigned long FW_CMemoryHeap::NumberAllocatedBlocks() const
- {
- return fNumberAllocatedBlocks;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::Reallocate
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void *FW_CMemoryHeap::Reallocate(void *blk, FW_BlockSize newSize)
- {
- if (blk == NULL)
- return this->Allocate(newSize);
-
- FW_BlockSize allocatedSize;
- FW_BlockSize oldBlkSize = (FW_BlockSize) this->DoBlockSize(blk);
-
- #ifdef FW_DEBUG
- this->CallAboutToReallocHooks(blk, newSize);
- #endif
-
- blk = this->DoReallocate(blk, newSize, allocatedSize);
-
- if (blk != NULL)
- fBytesAllocated += allocatedSize - oldBlkSize;
-
- #ifdef FW_DEBUG
- blk = this->CallDidAllocateHooks(blk, newSize);
- #endif
-
- return blk;
- }
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::RemoveHook (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::RemoveHook(FW_CMemoryHook *memoryHook)
- {
- fMemoryHookList.Remove(memoryHook);
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::Reset
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::Reset()
- {
- #ifdef FW_DEBUG
- this->CallAboutToResetHooks();
- #endif
-
- fBytesAllocated = 0;
- fNumberAllocatedBlocks = 0;
-
- this->DoReset();
- }
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::SetAutoValidation (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::SetAutoValidation(Boolean autoValidation)
- {
- fAutoValidation = autoValidation;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::SetDescription (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::SetDescription(const char *description)
- {
- // ------ Set the description without depending on other code
-
- const char *src = description;
- char *dst = fDescription;
- int i;
-
- for (i = 0; i < kDescriptionLength - 1 && *src; i++)
- *dst++ = *src++;
- fDescription[i] = 0;
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::SetZapOnAllocate
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::SetZapOnAllocate(Boolean zapOnAllocate)
- {
- fZapOnAllocate = zapOnAllocate;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::SetZapOnFree
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::SetZapOnFree(Boolean zapOnFree)
- {
- fZapOnFree = zapOnFree;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::~FW_CMemoryHeap
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_CMemoryHeap::~FW_CMemoryHeap()
- {
- // Remove from the static list of heaps
-
- FW_CMemoryHeap *lastHeap = NULL, *currentHeap = fHeapList;
-
- while (currentHeap != NULL)
- {
- if (this == currentHeap)
- {
- if (lastHeap == NULL)
- fHeapList = currentHeap->GetNextHeap();
- else
- lastHeap->fNextHeap = currentHeap->GetNextHeap();
-
- currentHeap = NULL;
- }
- else
- {
- lastHeap = currentHeap;
- currentHeap = currentHeap->GetNextHeap();
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::FW_CMemoryHeap
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_CMemoryHeap::FW_CMemoryHeap(Boolean autoValidation,
- Boolean zapOnAllocate,
- Boolean zapOnFree)
- {
- #ifdef FW_DEBUG
- // ------ Set the default description without depending on other code
-
- const char *src = kDefaultDescription;
- char *dst = fDescription;
- for (; *src;)
- *dst++ = *src++;
- *dst = 0;
- #endif
-
- fAutoValidation = autoValidation;
- fZapOnAllocate = zapOnAllocate;
- fZapOnFree = zapOnFree;
- fBytesAllocated = 0;
- fNumberAllocatedBlocks = 0;
-
- // Add to the static list of heaps
-
- fNextHeap = fHeapList;
- fHeapList = this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::operator new
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void* FW_CMemoryHeap::operator new(SIZE_T size)
- {
- return PlatformAllocateBlock(size);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::operator delete
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::operator delete(void* ptr)
- {
- PlatformFreeBlock(ptr);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::AllocateRawMemory
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void *FW_CMemoryHeap::AllocateRawMemory(FW_BlockSize size)
- {
- return PlatformAllocateBlock(size);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::DoReallocate
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void *FW_CMemoryHeap::DoReallocate(void *block, FW_BlockSize newSize, FW_BlockSize &allocatedSize)
- {
- FW_BlockSize oldRealSize = this->DoBlockSize(block);
- void* newBlock = this->DoAllocate(newSize, allocatedSize);
-
- if (newBlock != NULL)
- {
- FW_BlockSize copySize = newSize <= oldRealSize ? newSize : oldRealSize;
- PlatformCopyMemory(block, newBlock, copySize);
-
- this->DoFree(block);
- }
- else
- if (newSize <= oldRealSize) //if unable to get new fMem, and newSize is <= real size
- return block; //then return original ptr unchanged
-
- return newBlock;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::FreeRawMemory
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::FreeRawMemory(void* ptr)
- {
- PlatformFreeBlock(ptr);
- }
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::CompilerCheck (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::CompilerCheck()
- {
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::CallAboutToAllocateHooks (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- FW_BlockSize FW_CMemoryHeap::CallAboutToAllocateHooks(FW_BlockSize size)
- {
- for (FW_CMemoryHook *hook = fMemoryHookList.First();
- hook != NULL; hook = fMemoryHookList.Next())
- size = hook->AboutToAllocate(size);
-
- return size;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::CallDidAllocateHooks (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void *FW_CMemoryHeap::CallDidAllocateHooks(void* blk, FW_BlockSize size)
- {
- for (FW_CMemoryHook *hook = fMemoryHookList.First();
- hook != NULL; hook = fMemoryHookList.Next())
- blk = hook->DidAllocate(blk, size);
-
- return blk;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::CallAboutToFW_BlockSizeHooks (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void *FW_CMemoryHeap::CallAboutToFW_BlockSizeHooks(void* blk)
- {
- for (FW_CMemoryHook *hook = fMemoryHookList.Last();
- hook != NULL; hook = fMemoryHookList.Previous())
- blk = hook->AboutToBlockSize(blk);
-
- return blk;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::CallAboutToFreeHooks (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void *FW_CMemoryHeap::CallAboutToFreeHooks(void* blk)
- {
- for (FW_CMemoryHook *hook = fMemoryHookList.Last();
- hook != NULL; hook = fMemoryHookList.Previous())
- blk = hook->AboutToFree(blk);
-
- return blk;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::CallAboutToReallocHooks (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::CallAboutToReallocHooks(void* &blk, FW_BlockSize& size)
- {
- for (FW_CMemoryHook *hook = fMemoryHookList.Last();
- hook != NULL; hook = fMemoryHookList.Previous())
- hook->AboutToRealloc(blk, size);
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::CallDidReallocHooks (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void *FW_CMemoryHeap::CallDidReallocHooks(void *blk, FW_BlockSize size)
- {
- for (FW_CMemoryHook *hook = fMemoryHookList.First();
- hook != NULL; hook = fMemoryHookList.Next())
- blk = hook->DidRealloc(blk, size);
-
- return blk;
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::CallAboutToResetHooks (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::CallAboutToResetHooks()
- {
- for (FW_CMemoryHook *hook = fMemoryHookList.First();
- hook != NULL; hook = fMemoryHookList.Next())
- hook->AboutToReset();
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::CallCommentHooks (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::CallCommentHooks(const char* comment)
- {
- for (FW_CMemoryHook *hook = fMemoryHookList.First();
- hook != NULL; hook = fMemoryHookList.Next())
- hook->Comment(comment);
- }
- #endif
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CMemoryHeap::ValidateAndReport (FW_DEBUG only)
- //----------------------------------------------------------------------------------------
- #pragma segment HeapSeg
-
- void FW_CMemoryHeap::ValidateAndReport(void *blk) const
- {
- PLATFORM_ASSERT(this->IsValidBlock(blk));
- }
- #endif
-